<!DOCTYPE HTML>
<html lang="en">
<head>
<title>CoordMode - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The CoordMode command sets coordinate mode for various commands to be relative to either the active window or the screen." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>CoordMode</h1>

<p>Sets coordinate mode for various commands to be relative to either the active window or the screen.</p>

<pre class="Syntax"><span class="func">CoordMode</span>, TargetType <span class="optional">, RelativeTo</span></pre>
<h2>Parameters</h2>
<dl>

  <dt>TargetType</dt>
  <dd>
    <p>The type of target to affect. Specify one of the following words:</p>
    <p><strong>ToolTip</strong>: Affects <a href="ToolTip.htm">ToolTip</a>.</p>
    <p><strong>Pixel</strong>: Affects <a href="PixelGetColor.htm">PixelGetColor</a>, <a href="PixelSearch.htm">PixelSearch</a>, and <a href="ImageSearch.htm">ImageSearch</a>.</p>
    <p><strong>Mouse</strong>: Affects <a href="MouseGetPos.htm">MouseGetPos</a>, <a href="Click.htm">Click</a>, and <a href="MouseMove.htm">MouseMove</a>/<a href="MouseClick.htm">Click</a>/<a href="MouseClickDrag.htm">Drag</a>.</p>
    <p><strong>Caret</strong>: Affects the built-in variables <a href="../Variables.htm#Caret">A_CaretX</a> and <a href="../Variables.htm#Caret">A_CaretY</a>.</p>
    <p><strong>Menu</strong>: Affects the <a href="Menu.htm#Show">Menu Show</a> command when coordinates are specified for it.</p>
  </dd>

  <dt>RelativeTo</dt>
  <dd>
      <p>The area to which <em>TargetType</em> is to be related. Specify one of the following words (if omitted, it defaults to Screen):</p>
      <p><strong>Screen</strong>: Coordinates are relative to the desktop (entire screen).</p>
      <p><strong>Relative</strong>: Coordinates are relative to the active window.</p>
      <p><strong>Window</strong> <span class="ver">[v1.1.05+]</span>: Synonymous with <em>Relative</em> and recommended for clarity.</p>
      <p><strong>Client</strong> <span class="ver">[v1.1.05+]</span>: Coordinates are relative to the active window's client area, which excludes the window's title bar, menu (if it has a standard one) and borders.  Client coordinates are less dependent on OS version and theme.</p>
  </dd>

</dl>

<h2>Remarks</h2>
<p>If this command is not used, all commands except those documented otherwise (e.g. <a href="WinMove.htm">WinMove</a> and <a href="InputBox.htm">InputBox</a>) use coordinates that are relative to the active window.</p>
<p>Every newly launched <a href="../misc/Threads.htm">thread</a> (such as a <a href="../Hotkeys.htm">hotkey</a>, <a href="Menu.htm">custom menu item</a>, or <a href="SetTimer.htm">timed</a> subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).</p>
<p><span class="ver">[v1.1.23+]:</span> The built-in <a href="../Variables.htm#CoordMode">A_CoordMode variables</a> contain the current settings.</p>
<h2>Related</h2>
<p><a href="Click.htm">Click</a>, <a href="MouseMove.htm">MouseMove</a>, <a href="MouseClick.htm">MouseClick</a>, <a href="MouseClickDrag.htm">MouseClickDrag</a>, <a href="MouseGetPos.htm">MouseGetPos</a>, <a href="PixelGetColor.htm">PixelGetColor</a>, <a href="PixelSearch.htm">PixelSearch</a>, <a href="ToolTip.htm">ToolTip</a>, <a href="Menu.htm">Menu</a></p>
<h2>Examples</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>CoordMode, ToolTip, Screen  <em>; Place ToolTips at absolute screen coordinates.</em>
CoordMode, ToolTip  <em>; Same effect as the above because &quot;screen&quot; is the default.</em></pre>
</div>

</body>
</html>
